package it.blueocean.acanto.taglibrary.jsp.taglib.tags.dataset.filter;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Operators
{
	private static Properties operatorsMap_;

	private final static Logger logger_ = LoggerFactory.getLogger(Operators.class);
	
	public static String getExpression(String paramString1, String paramString2, boolean paramBoolean)
	{
		String str = operatorsMap_.getProperty(paramString2);
		if(str == null)
		{
			logger_.warn("operator " + paramString2 + " was not mapped, using it as it is");
			str = paramString2;
		}
		str = str.replaceAll("\\$fieldName", paramString1);
		return str;
	}

	static
	{
		operatorsMap_ = new Properties();
		try
		{
			InputStream localInputStream = Operators.class.getResourceAsStream("operatorsMapping.properties");
			if(localInputStream == null)
				throw new FileNotFoundException();
			operatorsMap_.load(localInputStream);
		}
		catch (IOException localIOException)
		{
			logger_.warn("No operators mapping defined, resource operatorsMapping.properties not found");
		}
	}
}
